home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 8 / The Pier Shareware #8 (The Pier Exchange) (1996).ISO / 051 / ci_api.txt < prev    next >
Text File  |  1995-10-05  |  41KB  |  1,178 lines

  1.  
  2.  █▀▀                     █   █▀▀▀▀█ █▀▀▀▀█ ▀▀█▀▀
  3.  █   ▄▄▄ ▄▄▄ ▄ ▄ ▄▄▄ ▄▄▄ █   █▄▄▄▄█ █▄▄▄▄█   █   TBBS Server Control System
  4.  █   █ █ █▄█ █▄█  █   █  █   █    █ █        █   With Task Scheduler Serving
  5.  █▄▄ █▄█ █    █  ▄█▄  █  ▄   █    █ █      ▄▄█▄▄ Up To 10 Simultaneous Tasks!
  6.  ───────────────────────────────────────────────────────────────────────────
  7.                                VERSION 4.1
  8.                  A PRODUCT OF ADVANCED SYSTEMS RESEARCH
  9.                        API written by Alan McNamee
  10.  
  11. What is it?
  12. ───────────
  13.  
  14. Copyit! is a stand alone dos application designed to act as a co-processor
  15. to a LAN BASED TBBS system.  This topology and methodology enables TDBS and
  16. TBBS applications to request another processor to perform operations and
  17. tasks that could either not be performed by TBBS or would be better suited
  18. to being performed by another machine thus freeing TBBS of the task.  This
  19. is very well suited to such high impact operations as CD-ROM access and
  20. disk search applications.
  21.  
  22. Simply, Copyit! is a request processing system that was designed to enable
  23. a multi-line system to process task requests from many lines simultaneously.
  24. With its hand full of both general and specialize request types, Copyit!
  25. can provide a nearly unlimited range of services to the requesting
  26. Copyit! aware application.
  27.  
  28.  
  29. History
  30. ───────
  31.  
  32. Copyit! originated as an idea conceived by Rick Kosick in order to relieved
  33. the impact felt by the access of CD-Roms with a file management program that
  34. he had developed.  That first version was not much more than a compiled
  35. batch file in PASCAL that had a very specific task which was to wait for
  36. the presence of a file and then make dos calls to copy the requested file
  37. back to his programs holding area.  This one rather simply process conceived
  38. the entire idea of having another machine take the load off of TBBS and
  39. do robotic processes which an application could synchronize with to enable
  40. DOS ONLY operations to be access via TBBS.
  41.  
  42. The introduction of ASR to Copyit's maturity came forth with the 2nd version
  43. in which the basic design and look changed dramatically.  Version 2 was
  44. rewritten in 'C' and released with the basic LOOK of sysmon and brought with
  45. it the first version that could process free form instructions and not
  46. just file transfers. This version was released for the LAN based option of
  47. the FILEMAN 2.x version.  After the completion of the Fileman integration
  48. and getting all of the request protocols ironed out, a number of ASR products
  49. where developed to interface Copyit! and provide TBBS abilities that it
  50. never before could perform such as online tape backup, file
  51. archiving/unarchiving, etc.
  52.  
  53. Version 3.x took yet another complete rewrite by completely changing the
  54. internal processing structure and migrating the code over to
  55. CLIPPER 5.1 and 'C'.  At this time another complete face lift was given
  56. to Copyit to just make it prettier and give a more ergonomic appearance
  57. to the way that it processed its tasks.  During the 3.x versions the
  58. release of Tims 1.1 was completed and this gave us an opportunity to test
  59. the existing architecture to see how quickly development of a real time
  60. event handler could be made into the existing structure.  Without modifying
  61. any of the underlying structure, a complete realtime echo mail event
  62. processor was developed in under 6 hours.
  63.  
  64. This now brings us to the present.  The release of version 4.x came with
  65. some very substantial enhancements.  Primarily the architecture was opened
  66. up so that custom NON ASR applications could be developed using the
  67. Copyit interface and the Copyit! API.  This included 7 primary TYPES of
  68. basic operations that would allow just about any conceived application
  69. to access Copyit and instruct it to perform its bidding without regard
  70. to any other application that may being doing the same thing at the same
  71. time.  Additionally, version 4.x was brought forth with a REALTIME FAX
  72. interface that would allow any TDBS application to generate a full
  73. graphic fax and send it immediately with as little a 14 lines of code.
  74.  
  75.  
  76.  
  77. Architecture of the request file
  78. ────────────────────────────────
  79.  
  80. The basic components of the Copyit request file mechanism allows for a
  81. variety of combinations of its data types to form its basic operational
  82. instruction set.
  83.  
  84. Here is the request files component structure.
  85.  
  86. Fld  Fieldname  Length  Dec.  Fieldtype
  87. ─────────────────────────────────────────
  88.  
  89.  1   REQ_TYPE       2     0   Chr
  90.  2   SRC_FILE     100     0   Chr
  91.  3   DEST_PATH    100     0   Chr
  92.  4   CTRL_PATH    100     0   Chr
  93.  5   XTRACT_CMD   100     0   Chr
  94.  6   GIFDSK_RES     1     0   Chr
  95.  7   ERRORLEVEL     2     0   Num
  96.  8   LICENSE       35     0   Chr
  97.  9   ERROR          1     0   Log
  98. 10   ERRMSG       100     0   Chr
  99. 11   S_TASKTYPE     9     0   Chr
  100. 12   S_LINENUMB     9     0   Chr
  101. 13   S_SYSTMSG     14     0   Chr
  102. 14   SDATE          8     0   Date
  103. 15   STIME         10     0   Num
  104. 16   COVER          1     0   Log
  105. 17   PAGELENGTH     5     2   Num
  106. 18   NOLOGO         1     0   Log
  107.  
  108. Fields 1-13 are generic and are used for many different types of request
  109. operations and fields 14-18 only have meaning when performing a fax request.
  110.  
  111. Since Copyit works off of primary REQUEST TYPES, I will try to put forth
  112. its operation by showing the utilization of the request file with each
  113. request type.
  114.  
  115. The following are the 7 currently available request types.
  116.  
  117.  VALUE     FUNCTION
  118.  
  119.   1         File(s) Transfer
  120.   2         Gif Compression
  121.   3         Dos Program Execution
  122.   4         Exit on Errorlevel
  123.   5         Fax Transmission
  124.   6         Cold Boot
  125.   7         Warm Boot
  126.  
  127.  
  128. The following will be a brief description of the purpose of each of the
  129. general purpose fields:
  130.  
  131.  1   REQ_TYPE       2     0   Chr    This field must contain on of the 7
  132.                                      valid request type values.  This gives
  133.                                      Copyit! information on how to process
  134.                                      the other fields.
  135.  
  136.  2   SRC_FILE     100     0   Chr    This field when used with a type 1
  137.                                      file transfer, tells copyit the
  138.                                      full path and filename of the file to
  139.                                      access.  When used with a type 5 fax
  140.                                      transmission, it is only meaningful
  141.                                      if a txt, pcx or dcx file is attached
  142.                                      to the transmission as part of the
  143.                                      body of the fax.
  144.  
  145.  3   DEST_PATH    100     0   Chr    This field when used with a type 1
  146.                                      tells copyit where to send the
  147.                                      file accessed in the SRC_FILE file.
  148.                                      This must be a full path that
  149.                                      is NOT terminated by a \
  150.  
  151.  4   CTRL_PATH    100     0   Chr    This field is used when the sending
  152.                                      application must wait for a response
  153.                                      from copyit that signals the
  154.                                      completion of the task.  This must
  155.                                      be a full path that IS terminated
  156.                                      by a \ .  When used with a type 5
  157.                                      Fax Transmission this field is used
  158.                                      for the TO | FROM that is made a
  159.                                      part of the cover sheet if one is
  160.                                      instructed to be included.
  161.  
  162.  5   XTRACT_CMD   100     0   Chr    This field is used primarily with
  163.                                      the type 3 Dos program execution.
  164.                                      This field will contain the Dos
  165.                                      command line that is to be invoked
  166.                                      by Copyit.  When used with a type
  167.                                      5 Fax Transmission, this field will
  168.                                      contain the Full Telephone number to
  169.                                      be used to dial the Target fax
  170.                                      machine.
  171.  
  172.  6   GIFDSK_RES     1     0   Chr    This field is primarily used with
  173.                                      the type 2 Gif Compression.  This
  174.                                      field contains the compression
  175.                                      percentage as a value between 1 and
  176.                                      4 where 1 is 100% and 4 is 6%.
  177.                                      This field is also used with the
  178.                                      type 5 Fax Transmission to instruct
  179.                                      copyit to what resolution to use
  180.                                      when sending the fax, a 0 is HIGHRES
  181.                                      and a value of 1 is LOWRES.
  182.  
  183.  7   ERRORLEVEL     2     0   Num    This field is primarily used with
  184.                                      the type 4 Exit with ErrorLevel.
  185.                                      The value used with this field can
  186.                                      be between 0 and 255.  This field
  187.                                      is also used with the type 5 Fax
  188.                                      Transmission to instruct copyit
  189.                                      to used either normal text or
  190.                                      compressed text for the fax
  191.                                      transmission.  A value of 0 is
  192.                                      NORMALTEXT and a value of 1 is
  193.                                      COMPRESSEDTEXT.
  194.  
  195.  8   LICENSE       35     0   Chr    This field is used by copyit to
  196.                                      return the copyit licensing
  197.                                      information to the requesting
  198.                                      application.
  199.  
  200.  9   ERROR          1     0   Log    This field is used by copyit to
  201.                                      tell the requesting application that
  202.                                      an error occurred during the requested
  203.                                      task.  If used with a type 5 fax
  204.                                      transmission, this field will be
  205.                                      used to ...
  206.  
  207. 10   ERRMSG       100     0   Chr    This field is used by copyit to
  208.                                      tell the requesting application the
  209.                                      nature of the error that occurred
  210.                                      from a failed request.  If used
  211.                                      with a type 5 fax transmission this
  212.                                      field will contain the name of a
  213.                                      pcx field to be used as the cover
  214.                                      sheet graphic if one is intended to
  215.                                      be a part of the transmission.
  216.                                      This will be the filename only as
  217.                                      all logofiles must be in the path
  218.                                      that is configured by the copyit
  219.                                      fax configuration.
  220.  
  221.  
  222. 11   S_TASKTYPE     9     0   Chr    This field is used for the
  223.                                      string information that is to be
  224.                                      displayed on the copyit console
  225.                                      when the task is received.
  226.  
  227. 12   S_LINENUMB     9     0   Chr    This field is used for the console
  228.                                      display of the line number of the
  229.                                      application making the request.
  230.  
  231. 13   S_SYSTMSG     14     0   Chr    This field is used for the copyit
  232.                                      console display of the messages
  233.                                      the indications the activity of
  234.                                      the application request.
  235.  
  236.  
  237.  
  238. The following will be a brief description of the purpose of each of the
  239. Fax Transmission specific fields:
  240.  
  241.  
  242. 14   SDATE          8     0   Date   This field is used to specify the
  243.                                      date that the fax is to be transmitted.
  244.                                      If left empty the fax will be sent
  245.                                      immediately.  If a date is used then the
  246.                                      STIME field must contain a value.
  247.  
  248. 15   STIME         10     0   Num    This field is used to specify the
  249.                                      time that the fax is to be transmitted.
  250.                                      If the SDATE field contains a date and
  251.                                      the STIME field contains a time which
  252.                                      is entered as the number of seconds
  253.                                      since midnight, then the fax will be
  254.                                      transmitted at that date and time.
  255.  
  256. 16   COVER          1     0   Log    This boolean field can be either true
  257.                                      or false.  If true then a cover sheet
  258.                                      will be sent with the fax with option
  259.                                      cover sheet text.  If False no cover
  260.                                      sheet will be used and no cover sheet
  261.                                      text may be used.
  262.  
  263. 17   PAGELENGTH     5     2   Num    This field is for entering the page
  264.                                      length to be used.  Normally 11.5 inchs
  265.                                      is used but this can be any value.  If
  266.                                      a value of 0 is entered then the fax
  267.                                      will be continuous pages.
  268.  
  269. 18   NOLOGO         1     0   Log    This field is to specified if a pcx
  270.                                      logo file will be attached to the cover
  271.                                      sheet.  If true, no pcx file will be
  272.                                      used in the coversheet, if false, one
  273.                                      will be used.
  274.  
  275.  
  276. Application/Copyit Interaction
  277. ──────────────────────────────
  278.  
  279. In some cases with some request types, interaction between the TDBS
  280. application and copyit will take place.  For example, when a type 1 file
  281. transfer request is made, the TDBS application first prepares the request
  282. file from the req.dbf structure.  This req.dbf structure is copied to a file
  283. called  'req'+uline()+'.dbf'.  This creates a unique request file for the
  284. line that is using the application.  The application then fills in the
  285. appropriate information into the request file and then copies the request
  286. file to the COPYIT DIRECTORY.  Copyit will automatically detect the presence
  287. of the request file and begin processing it.  The TDBS application then must
  288. wait for acknowledgement from Copyit that the request has been fully processed
  289. or that it is ok for the application to proceed.
  290.  
  291. This acknowledgement comes in the form of a file event with the file always
  292. begin "RECEIVED.FLG".  This file should be instructed in the file request to
  293. be sent to a private directory for that callers line number, something in the
  294. form on 'line'+uline()+'\'.  This insures that any other line that may be
  295. doing the same process, will not create a conflict with another line.
  296.  
  297. In addition, the receive flag may be a start signal for a process that may
  298. be started by the application but is not complete on the copyit side.  After
  299. the complete operation has been done by copyit, copyit will send back a
  300. file called 'RES'+ULINE()+'.DBF'.  This file will normally be empty unless
  301. and error had been detected by copyit during the process.  In the case of
  302. an error, each record in the file will be a brief description of the error.
  303.  
  304. The application must also know that copyit is currently available for
  305. processing the incoming requests.  This is done by examining the copyit
  306. directory for the file NETBUSY.FLG.  If this file exists then copyit is
  307. currently not available to process requests.  Normally this suggests that
  308. copyit is out under an errorlevel process or offline.  In order to maintain
  309. application integrity, normally you would continue to process for up to
  310. 30 seconds waiting for the NETBUSY.FLG to disappear and if it does not then
  311. instruct the application to abort the request process.
  312.  
  313.  
  314. Coding Examples
  315. ───────────────
  316.  
  317. The following code example is an extract from the ASR Fileman program and
  318. illustrates a batch file request of a type 1 request value.  This shows the
  319. preparation of the request file and the start signal wait process.
  320.  
  321.  
  322. **** BEGIN BATCH FILE TRANSFER CODING EXAMPLE ****
  323.  
  324. proc download
  325. drrec=recno()
  326. d=0
  327. use
  328. select 1
  329. use &mqholdfile
  330. select 2
  331. use fardata
  332. set index to fararea
  333. select 3
  334. use fileman
  335. set index to fname
  336. usecds=.f.
  337. mserv2que=" "
  338. do while .t.
  339.    d=d+1
  340.    mcdserver=.f.
  341.    mcdpath=""
  342.    mfcdpath=""
  343.    if empty(adownload[d])
  344.      d=0
  345.      exit
  346.    endif
  347.    sval=upper(trim(adownload[d]))
  348.  
  349.    select 3
  350.    seek sval
  351.    if found()
  352.       sval=arealvl+area_no
  353.    endif
  354.    select 2
  355.    seek sval
  356.    if found()
  357.       if cdserver
  358.          usecds=.t.
  359.          mcdserver=.t.
  360.          mcdpath=upper(trim(cdspath))
  361.          mfcdpath=lower(trim(farpath))
  362.          mserv2que=serv2que
  363.       endif
  364.    endif
  365.    select 1
  366.    append blank
  367.    replace holdfile with adownload[d]
  368.    replace lastuser with uname()
  369.    replace cdserver with mcdserver
  370.    replace cdpath with mcdpath
  371.    replace fcdpath with mfcdpath
  372.    replace serv2que with mserv2que
  373. enddo
  374.  
  375. select 2
  376. use
  377. select 3
  378. use
  379. select 1
  380. goto top
  381. ?
  382. qdir=mqdirs+"line"+uline+"\"
  383. do dnldel
  384. tot24hr=ulpeek(165,4)
  385. multi=.f.
  386.  
  387. if usecds
  388.    quedirflg=mqdirs+"LINE"+uline+"\RECEIVED.FLG"
  389.    queerr=mqdirs+"LINE"+uline+"\ERROR00.LOG"
  390.    ? "Sending requests to Server #"+servnum+"..."
  391.    d=0
  392.    l=0
  393.    ?? chr(7)
  394.    do while .t.
  395.       d=d+1
  396.       if cdserver
  397.          l=l+1
  398.          if l=1
  399.             path2ser=trim(cdpath)
  400.             mapped2=serv2que
  401.             svar="REQ"+uline+".DBF"
  402.             s=svar
  403.             svar=path2ser+svar
  404.             select 7
  405.             use req.dbf
  406.             copy stru to &s
  407.             use
  408.             use &s
  409.             select 1
  410.             set color to w/n
  411.             ? trim(holdfile)
  412.             holdfile2=holdfile
  413.             fcdpath2=fcdpath
  414.             qdir2=qdir
  415.             select 7
  416.             append blank
  417.             repl req_type with "1"
  418.             repl src_file with trim(fcdpath2)+trim(holdfile2)
  419.             repl dest_path with mapped2+SUBS(qdir2,2,LEN(TRIM(qdir2))-2)
  420.             repl ctrl_path with mapped2+SUBS(mqdirs,2)
  421.             repl s_tasktype with "File Req"
  422.             repl s_linenumb with "  "+uline
  423.             repl s_systmsg with " File "+str(l,2,0)
  424.             select 1
  425.             if eof()
  426.                select 7
  427.                use
  428.                select 1
  429.                copy file &s to &svar
  430.                exit
  431.             else
  432.                skip
  433.             endif
  434.             loop
  435.          endif
  436.          set color to w/n
  437.          ? trim(holdfile)
  438.          holdfile2=holdfile
  439.          fcdpath2=fcdpath
  440.          qdir2=qdir
  441.          select 7
  442.          append blank
  443.          repl src_file with trim(fcdpath2)+trim(holdfile2)
  444.          repl s_systmsg with " File "+str(l,2,0)
  445.          select 1
  446.       endif
  447.       if eof()
  448.          select 7
  449.          use
  450.          select 1
  451.          copy file &s to &svar
  452.          exit
  453.       else
  454.          skip
  455.       endif
  456.    enddo
  457.    path2ser=path2ser+sval
  458.    tof="sval"
  459. endif
  460. select 1
  461. use
  462. select 2
  463. use
  464. d=0
  465. qfilesize=0
  466. mcdserver=.f.
  467. if .not. empty(adownload[2])
  468.    multi=.t.
  469.    ?? chr(7)
  470.    set color to w+/n
  471.    dummy=afill(afilename,space(1))
  472.    dummy=afill(afilesize,0,i+1)
  473.    dummy=afill(afiledate,"01/01/80")
  474.    dummy=afill(afiledesc,space(1))
  475.    dummy=afill(arec,0)
  476.    dummy=afill(aonline,.f.)
  477.    dummy=afill(xtn,.f.)
  478.    ? "Copying files to queue..."
  479.  
  480.    select 1
  481.    use fardata
  482.    set index to fararea
  483.  
  484.    select 2
  485.    use fileman
  486.    set index to fname
  487.    do while .t.
  488.       mcdserver=.f.
  489.       d=d+1
  490.       if empty(adownload[d])
  491.          exit
  492.       endif
  493.       dfilename=trim(adownload[d])
  494.       select 2
  495.       seek dfilename
  496.       if found()
  497.          findarea=arealvl+area_no
  498.          select 1
  499.          seek findarea
  500.          mfn=TRIM(farpath)
  501.          mcdspath=TRIM(cdspath)
  502.          mcdserver=cdserver
  503.          select 2
  504.          ffilename=mfn+dfilename
  505.          qdir=mqdirs+"line"+uline+"\"+dfilename
  506.          if .not. mcdserver
  507.             qfilesize=qfilesize+size
  508.          endif
  509.          if .not. mcdserver
  510.             set color to w/n
  511.             ? ffilename
  512.             do binarycopy with ffilename,qdir
  513.          endif
  514.       endif
  515.    enddo
  516.    select 1
  517.    use
  518.    select 2
  519.    use
  520.  
  521.    **** prompt for logoff
  522.    if mlogoff
  523.       if mlogoff
  524.          do lineprmpt with "Logoff after Download [y/N] "
  525.          ans=upper(trim(cvar))
  526.          if ans="Y"
  527.             loff=.t.
  528.          endif
  529.       endif
  530.    endif
  531.  
  532.    qdir=mqdirs+'line'+uline+' /TL /NL /I:"D *.*"'
  533.  
  534.    **** begin batch download
  535.    if usecds
  536.       ? "Waiting for requests, Esc to Abort "
  537.    endif
  538.    qq=0
  539.    do while .t.
  540.       qq=qq+1
  541.       if usecds
  542.          do case
  543.             case qfilesize >=50000
  544.                clear
  545.                dotbbs type 34 optdata qdir
  546.                if file(quedirflg)
  547.                   dummy=inkey(1)
  548.                   do binaryerase with quedirflg
  549.                endif
  550.                exit
  551.             case file(quedirflg)
  552.                dummy=inkey(1)
  553.                do binaryerase with quedirflg
  554.                clear
  555.                dotbbs type 34 optdata qdir
  556.                exit
  557.             otherwise
  558.               if file(queerr)
  559.                 clear
  560.                 type &queerr
  561.                 dummy=inkey(1)
  562.                 do binaryerase with queerr
  563.                 wait
  564.                 exit
  565.               endif
  566.               ?? "."
  567.               if qq >= 120
  568.                  ?? chr(27)
  569.                  set color to r+/n
  570.                  ? "Server is not responding, Download Aborted!"
  571.                  dummy=inkey(2)
  572.                  use
  573.                  use fileman
  574.                  set index to farea,fname,dlstat,putol
  575.                  return
  576.               endif
  577.               dummy=inkey(1)
  578.               if dummy=27
  579.                  ?? chr(27)
  580.                  set color to r+/n
  581.                  ? "Download Aborted!"
  582.                  dummy=inkey(2)
  583.                  use
  584.                  use fileman
  585.                  set index to farea,fname,dlstat,putol
  586.                  return
  587.               endif
  588.               loop
  589.          endcase
  590.          if file(queerr)
  591.             clear
  592.             type &queerr
  593.             dummy=inkey(1)
  594.             do binaryerase with queerr
  595.             wait
  596.             exit
  597.          endif
  598.       else
  599.          clear
  600.          dotbbs type 34 optdata qdir
  601.          exit
  602.       endif
  603.    enddo
  604.    d=0
  605.    **** delete queued files
  606.    do dnldel
  607. else
  608.    ****  Single file downloads
  609.    ****  coding example omitted
  610.  
  611. endif
  612.  
  613. select 1
  614. use fileman
  615. set index to fname,farea,dlstat,putol
  616. select 2
  617. use fardata
  618. set index to fararea
  619. select 3
  620. use filecfg
  621. if usecds
  622.    resfile=mqdirs+"\RES"+uline+".DBF"
  623.    if file(resfile)
  624.       select 4
  625.       use &resfile
  626.       qq=0
  627.       if error
  628.          set color to gr+/n
  629.          ? " -Errors have been recorded, Press Any Key-"
  630.          dummy=inkey(6)
  631.          set color to gr+/n
  632.          clear
  633.          set color to gr+/b
  634.          ??'  Request ERRORS, The Following Requests where not processed'
  635.  
  636.          set color to r+/n
  637.          do while .t.
  638.             if eof()
  639.                exit
  640.             endif
  641.             qq=qq+1
  642.             if mod(qq,20)=0
  643.               set color to gr+/n
  644.               ? " -more-"
  645.               dummy=inkey(12)
  646.               clear
  647.               set color to gr+/b
  648.               ??'  Request ERRORS, The Following Requests where not process'
  649.               set color to r+/n
  650.             endif
  651.             if .not. empty(errmsg)
  652.                ? subs(errmsg,1,77)
  653.             else
  654.                qq=qq-1
  655.                skip
  656.                loop
  657.             endif
  658.             skip
  659.             if eof()
  660.                exit
  661.             endif
  662.          enddo
  663.          set color to gr+/n
  664.          ? " -Press Any Key-"
  665.          dummy=inkey(12)
  666.          clear
  667.       endif
  668.       use
  669.       select 3
  670.       if file(resfile)
  671.          do binaryerase with resfile
  672.       endif
  673.    endif
  674. endif
  675.  
  676. return
  677.  
  678. **** END CODING EXAMPLE ****
  679.  
  680.  
  681. The following code example is an extract from ASRchive which illustrates
  682. the type 3 request which allows an external dos application to be called
  683. from Copyit.  When copyit receives this request it will unload itself from
  684. memory except for a 4k resident portion that must remain.  The Dos
  685. application that you request the execution of will have all of the
  686. remaining available memory.
  687.  
  688. **** BEGIN CODING EXAMPLE ****
  689.  
  690.  
  691. line1=mmap+subs(mqdir,2)
  692. line2="Dummy"
  693.  
  694. *** line3 is the setup for a call to a batch file called asrzip.bat
  695. *** the rest of the parameters are the command line parameters for
  696. *** pkzip.exe that are accepted by the batch file with the %1 %2 %3 with
  697. *** the call to the batch file.
  698.  
  699. line3="asrzip temp.zip "+mmap+subs(mqdir,2)+"\que\*.* > asrchive.txt"
  700. use req.dbf
  701. copy stru to &reqfile
  702. use
  703. use &reqfile
  704. append blank
  705. repl req_type with "3"
  706. repl dest_path with line1
  707. repl ctrl_path with line1
  708. repl s_tasktype with "Archive"
  709. repl s_linenumb with "   "+ULINE()
  710. repl s_systmsg with trim(subs(filename,at(".",filename)+1))+" Archiving"
  711. repl xtract_cmd with line3
  712. use
  713.  
  714. mservtemp=mservpath+'\'+reqfile
  715. copy file &reqfile to &mservtemp
  716. qq=0
  717. set color to w+/r
  718. @ 15,7 say space(66)
  719. @ 15,7 say "Archiving "
  720.  
  721. do while .t.
  722.   qq=qq+1
  723.   if file("RECEIVED.FLG")
  724.      dummy=inkey(1)
  725.      erase received.flg
  726.      exit
  727.   endif
  728.   ?? "."
  729.   if qq >= 120
  730.      ?? chr(27)
  731.      set color to w+/r
  732.      @ 15,7 say space(66)
  733.      set color to w+*/r
  734.      @ 15,7 say "Server is not responding, Process Aborted!"
  735.      set color to w+/r
  736.      dummy=inkey(4)
  737.      @ 15,7 say space(66)
  738.      use
  739.      return
  740.   endif
  741.   dummy=inkey(1)
  742. enddo
  743.  
  744. if file("ERROR00.LOG")
  745.    dummy=INKEY(1)
  746.    errfile=mqdir+"\error00.log"
  747.    erase error00.log
  748. endif
  749.  
  750. @ 15,7 say space(66)
  751. @ 15,7 say "Copying work file to "+filename +" ..."
  752. copy file temp.zip to &filename
  753. dummy=inkey(2)
  754.  
  755. **** END CODING EXAMPLE ****
  756.  
  757. The following code example is an extract from tapeman which illustrates
  758. the exit on errorlevel from a type 4 request.
  759.  
  760. **** BEGIN CODING EXAMPLE ****
  761.  
  762. if dotape
  763.    s="REQ"+uline()+".DBF"
  764.    use req.dbf
  765.    copy stru to &s
  766.    use
  767.    use &s
  768.    append blank
  769.    repl req_type with "4"
  770.    repl errorlevel with 28
  771.    repl s_tasktype with "Tape BU"
  772.    repl s_linenumb with "   "+ULINE()
  773.    repl s_systmsg with "Online Backup"
  774.    use
  775.    svar=mcpath+s
  776.    copy file &s to &svar
  777. endif
  778.  
  779. **** END CODING EXAMPLE ****
  780.  
  781.  
  782.  
  783.  
  784. The following code example is an extract from the credit card
  785. system that ASR uses for product purchases.  This program allows
  786. the caller to optionally request that the invoice for the purchase be
  787. faxed immediately rather than being sent in the mail.   This will show
  788. the method used to prepare the information that is to be faxed and
  789. then instructing copyit on how to send it.  This example sends both
  790. a full coversheet with a logo graphic and a body text which is the
  791. invoice iself.  This uses a type 5 request value.
  792.  
  793. **** BEGIN FAX CODING EXAMPLE ****
  794.  
  795. do while .t.
  796.       clear
  797.       faxit=.f.
  798.       ans=.f.
  799.       @ 2,3 say "Do you wish to have your invoice faxed immedietly?" GET ans PICT "Y"
  800.       read
  801.       if ans
  802.          faxit=.t.
  803.          fcountry = "  "
  804.          fareacode="   "
  805.          fphonenum="   -     "
  806.          ans=.t.
  807.          @ 4,3 say "Are you in the U.S. or Canada" get ans PICT "Y"
  808.          read
  809.          if .not. ans
  810.             @ 5,3 say "Enter your Country code" get fcountry pict "99"
  811.             read
  812.             @ 6,3 say "Enter your Area Code"
  813.             @ 5,29 say "-"
  814.             @ 5,30 get fareacode pict "999"
  815.             read
  816.             @ 7,3 say "Enter your fax number"
  817.             @ 5,33 say "-"
  818.             @ 5,34 get fphonenum pict "99999999"
  819.             read
  820.             ffaxnum="910288011"+fareacode+fphonenum
  821.          else
  822.             @ 5,3 say "Enter your Area Code"
  823.             @ 5,30 get fareacode pict "999"
  824.             read
  825.             @ 6,3 say "Enter your fax number"
  826.             @ 5,33 say "-"
  827.             @ 5,34 get fphonenum pict "999-9999"
  828.             read
  829.             if empty(fareacode) .or. fareacode="702"
  830.                ffaxnum="9"+fphonenum
  831.             else
  832.                ffaxnum="9102881"+fareacode+fphonenum
  833.             endif
  834.          endif
  835.          ans=.f.
  836.          @ 8,3 say "Is this correct" get ans pict "Y"
  837.          read
  838.          if ans
  839.             exit
  840.          else
  841.             loop
  842.          endif
  843.       else
  844.          exit
  845.       endif
  846. enddo
  847. clear
  848. set color to w+/B
  849. @ 1, 5 say "───┤ Save Purchase ├────────────────────────────────────────────── "
  850. @ 2, 5 say "                                                                   "
  851. @ 3, 5 say "  Thank You!  Your purchase has been saved in the database.        "
  852. if faxit
  853.    @ 4, 5 say "  FAXING your Invoice!   Please Wait ...                           "
  854. else
  855.    @ 4, 5 say "  Printing your Invoice!  Please Wait ...                          "
  856. endif
  857. @ 5, 5 say "                                                                   "
  858. if .not. prnonly
  859.    use card
  860.    append blank
  861.    replace entrydate  with date()
  862.    replace crdno      with m->crdno
  863.    replace crdtype    with m->crdtype
  864.    replace crdholder  with m->crdholder
  865.    replace crdexp     with m->crdexp
  866.    replace total      with m->total
  867.    replace addr1      with m->addr1
  868.    replace addr2      with m->addr2
  869.    replace city       with m->city
  870.    replace state      with m->state
  871.    replace zip        with m->zip
  872.    replace phone      with m->phone
  873.    replace expire     with m->expire
  874.    replace processed  with .f.
  875.    replace username   with uname
  876.    replace userloc    with ulocation()
  877.    replace auth       with "      "
  878.    replace product    with m->prodsel
  879. else
  880.    prodsel=space(60)
  881.    @ 6,5 say "Enter Product for Invoice" get prodsel
  882.    @ 7,5 say "Enter Amount of Purchase " get total pict "9999.99"
  883.    read
  884. endif
  885. set printer to lpt1
  886. set print on
  887. set console off
  888. ?
  889. ?
  890. ?
  891. ?
  892. ?
  893. ? "    The Advanced System Credit Card Transactions - Printed " + dtoc(date())
  894. ?
  895. ? "    ════════════════════════════════════════════════════════"
  896. ? "    Entry Date ....... " + dtoc(date())
  897. ? "    User Name ........ " + rtrim(uname)
  898. if .not. prnonly
  899. ? "    User Location  ... " + rtrim(userloc)
  900. endif
  901. ? "    ════════════════════════════════════════════════════════"
  902. ? "    Credit Card Number ..... " + rtrim(crdno)
  903. ? "    Credit Card Holder ..... " + rtrim(crdholder)
  904. ? "    Credit Card Expires .... " + rtrim(crdexp)
  905. ? "    Credit Card Type ....... " + rtrim(crdtype)
  906. ? "    Authorization Number ... "
  907. ? "    ════════════════════════════════════════════════════════"
  908. ? "    User Information:"
  909. ?
  910. ? "       " + rtrim(crdholder)
  911. ? "       " + rtrim(addr1)
  912. if .not. empty(rtrim(addr2))
  913.     ? "       " + rtrim(addr2)
  914. endif
  915. ? "       " + rtrim(city) + ", " + trim(state) + "  " + trim(zip)
  916. ?
  917. ? "       " + rtrim(phone)
  918. ? "       Key imbedded for: " + rtrim(bbsname)
  919. ? "    ════════════════════════════════════════════════════════"
  920. ?
  921. ? "    $"+str(total,6,2)+" - "+trim(prodsel)
  922. ? "    Programmer: "+mprgmr
  923. ? "    Percentage: "+STR(mprc,6,0)+"%"
  924. ?
  925. ? "    ════════════════════════════════════════════════════════"
  926. ?
  927. ? "    ___ Check User Record Updated"
  928. ?
  929. ? "    ___ Check Credit Card Slip Processed"
  930. ?
  931. ?
  932. ?
  933. do printbig with " "+rtrim(crdno)
  934. ?
  935. do printbig with " "+rtrim(crdexp)
  936. ?
  937. do printbig with " $"+str(total,6,2)
  938. eject
  939. if faxit
  940.    set print off
  941.    faxfile="FAX"+ULINE()+".BDY"
  942.    set alternate to &faxfile
  943.    set alternate on
  944. endif
  945. ?
  946. ?
  947. do bigletters
  948. ?
  949. ? "        The Advanced System Credit Card Transaction - Printed " + dtoc(date())
  950. ?
  951. ?
  952. ?
  953. ? "         " + rtrim(uname)
  954. ? "         " + rtrim(addr1)
  955. if .not. empty(rtrim(addr2))
  956.     ? "         " + rtrim(addr2)
  957. endif
  958. ? "         " + rtrim(city) + ", " + trim(state) + "  " + trim(zip)
  959. ?
  960. ?
  961. ?
  962. ?
  963. if empty(rtrim(addr2))
  964.     ?
  965. endif
  966. ? "-"
  967. ? "    " + rtrim(phone)
  968. ? "    Key Imbedded For: " + rtrim(bbsname)
  969. ? "    ════════════════════════════════════════════════════════"
  970. ? "    Entry Date ....... " + dtoc(date())
  971. ? "    Name ............. " + rtrim(uname)
  972. if .not. prnonly
  973.    ? "    Location  ........ " + rtrim(userloc)
  974. endif
  975. ? "    ════════════════════════════════════════════════════════"
  976. ? "    Credit Card Number ..... " + rtrim(crdno)
  977. ? "    Credit Card Holder ..... " + rtrim(crdholder)
  978. ? "    Credit Card Expires .... " + rtrim(crdexp)
  979. ? "    Credit Card Type ....... " + rtrim(crdtype)
  980. if prnonly
  981.    ? "    Authorization Number ... " +
  982. ltrim(rtrim(str(145,3,0)))+"-"+subs(dtoc(date()),7,2)+"-"+subs(dtoc(date()),1,2)
  983. else
  984.    ? "    Authorization Number ... " +
  985. ltrim(rtrim(str(recno(),10,0)))+"-"+subs(dtoc(date()),7,2)+"-"+subs(dtoc(date()),1,2)
  986. endif
  987. ? "    ════════════════════════════════════════════════════════"
  988. ? "    Purchase Information:"
  989. ?
  990. ? "    $"+str(total,6,2)+" - "+trim(prodsel)
  991. ? "    ════════════════════════════════════════════════════════"
  992. ?
  993. ? "    Note: All credit card transactions are processed by:"
  994. ? "          INCAD, Inc., In Partnership with Advanced Systems Research, Inc."
  995. ?
  996. ?
  997. do printbig with " "+rtrim(crdno)
  998. ?
  999. do printbig with " "+rtrim(crdexp)
  1000. ?
  1001. do printbig with " $"+str(total,6,2)
  1002. ?
  1003. ?
  1004. ?
  1005. ? "                         Advanced Systems Research, Inc."
  1006. ? "                            1475 Terminal Way Bldg C2"
  1007. ? "                                 Reno, Nv   89502"
  1008. ? "                     702-334-3304 (voice) -  702-334-3317 (bbs)"
  1009. ?
  1010. ? "                     Turning TBBS POSSIBILITIES into REALITIES!"
  1011. if faxit
  1012.    ? chr(12)
  1013. else
  1014.    eject
  1015. endif
  1016. if .not. prnonly
  1017.    replace processed with .t.
  1018. endif
  1019. if faxit
  1020.    set alternate off
  1021.    set alternate to
  1022.    reqfile="REQ"+ULINE()+".DBF"
  1023.    use req.dbf
  1024.    copy stru to &reqfile
  1025.    use
  1026.    use &reqfile
  1027.    append blank
  1028.  
  1029.    replace xtract_cmd with ffaxnum
  1030.                                       && the phone number of the
  1031.                                       && fax machine being called
  1032.  
  1033.    replace license with "CATMAN 1.0"
  1034.                                       && Name of application that
  1035.                                       && sent the fax
  1036.  
  1037.    replace ctrl_path with trim(uname())+"|Advanced Systems Research"
  1038.                                       && the to and from entries.
  1039.                                       && seperate with the | chr.
  1040.                                       && If the FROM and | are
  1041.                                       && are omitted, then the default
  1042.                                       && from the copyit fax setup
  1043.                                       && will be used.
  1044.  
  1045.    replace errmsg with "ASRFAX2.PCX"
  1046.                                       && the name of the pcx
  1047.                                       && cover page, uses default
  1048.                                       && in the copyit fax setup if
  1049.                                       && omitted.
  1050.  
  1051.    replace error with .f.             && always false
  1052.  
  1053.    replace gifdsk_res with "0"
  1054.                                       && resolution, 0=high, 1=low
  1055.  
  1056.    replace errorlevel with 0          && 0=NORMAL TEXT, 1=COMPRESSED
  1057.  
  1058.    replace req_type with "5"
  1059.                                       && task type 5 for faxing
  1060.  
  1061.    replace s_tasktype with "Send Fax"
  1062.    replace s_linenumb with "  "+uline()
  1063.    replace s_systmsg with " Invoice FAX"
  1064.                                       && copyit screen display info
  1065.  
  1066.    replace cover with .t.
  1067.                                       && true=use cover info, false=
  1068.                                       && don't use cover info
  1069.    replace pagelength with 11.0
  1070.                                       && fax page lenght
  1071.    replace nologo with .f.
  1072.                                       && false=use pcx cover sheet
  1073.                                       && true=don't use pcx cover sheet
  1074.  
  1075.    replace stime with 0
  1076.                                       && time to send fax, 0 immediately
  1077.  
  1078.    replace sdate with ctod("  /  /  ")
  1079.                                       && date to send fax, blank for
  1080.                                       && immediately
  1081.  
  1082.  
  1083.    && NOTE:
  1084.    && REPLACE SRC_FILE WITH THE NAME OF A FILE TO BE USED AS THE
  1085.    && BODY TEXT.  THIS CAN BE A TEXT, 200DPI B/W PCX OR A DCX FILE.
  1086.    && LEAVE THIS EMPTY IF NO BODY INFO WILL BE SENT.
  1087.    &&
  1088.    use
  1089.    faxfile="FAX"+ULINE()+".CVR"
  1090.    set alternate to &faxfile
  1091.    set alternate on
  1092.    ?
  1093.    ? "   This is your invoice for this transaction!  Since it has been FAXED"
  1094.    ? "   automatically using COPYIT! V4.1 you will not be receiving a invoice"
  1095.    ? "   by mail."
  1096.    ? "   "
  1097.    ? "   Alan McNamee"
  1098.    ? "   "
  1099.    set alternate off
  1100.    set alternate to
  1101.    faxfile="FAX"+ULINE()+".CVR"
  1102.    faxdest=COPYIT_PATH+faxfile
  1103.    copy file &faxfile to &faxdest
  1104.    faxfile="FAX"+ULINE()+".BDY"
  1105.    faxdest=COPYIT_PATH+faxfile
  1106.    copy file &faxfile to &faxdest
  1107.    faxdest=COPYIT_PATH+reqfile
  1108.    copy file &reqfile to &faxdest
  1109. else
  1110.    set print off
  1111. endif
  1112. set console on
  1113. if prnonly
  1114.    quit
  1115. endif
  1116.  
  1117. **** END CODING EXAMPLE ****
  1118.  
  1119.  
  1120.  
  1121. The following code example is an illustration of the types 6 and 7
  1122. machine reboot requests.  Normally this would be used as a prepared
  1123. request file which is sent over to copyit before the TBBS machine does
  1124. a reboot for an operation such as an automatic disk defrag process.  This
  1125. would require that the copyit machine be shut down and brought back up
  1126. to wait for the TBBS machine to reconnect.
  1127.  
  1128. **** BEGIN CODING EXAMPLE ****
  1129.  
  1130. s="REQ"+uline()+".DBF"
  1131. use req.dbf
  1132. copy stru to &s
  1133. use
  1134. use &s
  1135. append blank
  1136. repl req_type with "6"
  1137. ** note: use type 7 for a warm reboot
  1138. repl s_tasktype with "Reboot"
  1139. repl s_linenumb with "   "+ULINE()
  1140. repl s_systmsg with "Copyit Shutdwn"
  1141. use
  1142. svar=mcpath+s
  1143. copy file &s to &svar
  1144.  
  1145.  
  1146. **** END CODING EXAMPLE ****
  1147.  
  1148.  
  1149.  
  1150. The previous examples are by no means complete examples of the utility that
  1151. can be provided by the use of a copyit aware interface.  But by knowing the
  1152. elements and the rules of copyit many processes can be created that would
  1153. otherwise not be possible for an online application.
  1154.  
  1155. An example of a very extensive use would be an interface to the AS400
  1156. query system to request information from a company data system for online
  1157. access through a TBBS system.  This may sound difficult but it is actually
  1158. a very simple process and has already been done by one company to provide
  1159. information about flooring charges of computer equipment that dealers have
  1160. on hand.  This information may take quite awhile to generate the results
  1161. so instead of having the caller wait online while the results are computed
  1162. and translated into a ascii text file, the application issues the query
  1163. request then tells the caller that the results will be faxed back when they
  1164. are complete.  After the AS400 finishes its query process the TBBS system
  1165. then sends a second request (triggers by user logons) that invokes copyit
  1166. to fax the resulting text file to the original callers fax machine.  This
  1167. is all completing automatic and requires very little programming skill.
  1168.  
  1169.  
  1170. If you wish any additional information or help in interfacing your
  1171. application to copyit you can access the Advanced System BBS and leave
  1172. a message in the ASR Support Echo or call Advanced Systems Research Tech.
  1173. Support at 503-699-TBBS.
  1174.  
  1175.  
  1176. Alan McNamee
  1177.  
  1178.